/**
 *
 * @Author bian
 * @CreateDate 2016.12.7
 */
import "../base.js"

// action type
export const LOGIN = 'LOGIN'

const API_BASE = ""

// action functions
export function tryLogin(username, password) {
    return fetch("/api/admin_login",{ method: 'POST',
        body:    JSON.stringify({username,password}),
        headers: { 'Content-Type': 'application/json' },
        credentials : "same-origin"
    })
        .then(response => response.json())
        .then(json => {
                return {
                    type: LOGIN,
                    isAccountRight: json.isAccountRight,
                    isPwdRight: json.isPwdRight
                }
            }
        )
}